package com.dyw.springbootpersonal.service.impl;

import com.dyw.springbootpersonal.entity.User;
import com.dyw.springbootpersonal.mapper.UserMapper;
import com.dyw.springbootpersonal.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Devil
 * @create 2022-01-29-21:06
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> selectUsers() {
        return userMapper.getAll();
    }

    @Override
    public boolean insertUser(User user) {
        return userMapper.insertUser(user) > 0;
    }

    @Override
    public boolean deleteUserById(int id) {
        return userMapper.deleteById(id) > 0;
    }

    @Override
    public User selectById(int id) {
        return userMapper.getById(id);
    }

    @Override
    public boolean updateById(User user) {
        return userMapper.updateById(user) > 0;
    }
}
